package threads;

public class yieldExample {

	public static void main(String[] args) {
		Thread producer=new  Producer();
		Thread consumer=new  Consumer();
		producer.setPriority(Thread.MIN_PRIORITY);
		consumer.setPriority(Thread.MAX_PRIORITY);
		producer.start();
		consumer.start();

	}

}

class Producer extends Thread{
	
	public void run() {
		for(int i=0;i<5;i++) {
			System.out.println("Producer   "+i);
			Thread.yield();
		}
	}
	
}

class Consumer extends Thread{
	
	public void run() {
		for(int i=0;i<5;i++) {
			System.out.println("Consumer   "+i);
			Thread.yield();
		}
	}
	
}